package CustomPlugins;



import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;


public class Events implements Listener{
	public Events(CustomPlugins plugin){
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}
	
	//Event /plugins
	
	@EventHandler
	(priority = EventPriority.HIGHEST)
	public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
		
		Player p = event.getPlayer();
		
		if((event.getMessage().toLowerCase().startsWith("/plugins")) ||
			(event.getMessage().toLowerCase().startsWith("/pl "))  ||
			(event.getMessage().toLowerCase().equals("/pl")))
		{
			if(!event.getPlayer().isOp()) {
				event.setCancelled(false);
				
				p.sendMessage(ChatColor.RED + "Unknown command. Try /help for a list of commands.");				
				
			}
		}
			
			
			
		
		}
		//Event /about
		
		@EventHandler
		(priority = EventPriority.HIGHEST)
		public void onPlayerCommandPreprocessEventVersion(PlayerCommandPreprocessEvent event) {
			
			Player p = event.getPlayer();
			
			if((event.getMessage().toLowerCase().startsWith("/about")) ||
				(event.getMessage().toLowerCase().startsWith("/version ")))
			{
				if(!event.getPlayer().isOp()) {
					event.setCancelled(false);
					
					p.sendMessage(ChatColor.RED + "Unknown command. Try /help for a list of commands.");				
					
				}
				
				
				
			
			}
	}
	
	
	    
	}
	



